import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
import type { ResultType } from "@/utils/http/types";

/** 获取系统管理-部门管理列表 */
export const getDeptList = (data?: object) => {
  return http.request<ResultType>("post", baseUrlApi("/department/get_list"), {
    data
  });
};

/**
 * 获取部门树形结构
 * @param data 条件
 * @returns
 */
export const getDeptTree = (data?: object) => {
  return http.request<ResultType>("post", baseUrlApi("/department/get_tree"), {
    data
  });
};

export const setDepartmentData = (data?: object) => {
  return http.request<ResultType>("post", baseUrlApi("/department/save_data"), {
    data
  });
};

// 删除部门
export const delDepartmentData = (id: number) => {
  return http.request<ResultType>("get", baseUrlApi("/department/del_data"), {
    params: { id }
  });
};
